home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
C for beginners.adf
/
source
/
fread.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-01-17
|
745b
|
34 lines
/* fread.c 23.3 */
#include<stdio.h>
#define NUM_DATA (sizeof(data)/sizeof(long))
long data[] =
{
4711, 815, 1024, 1, 31415926, 0, -13, 10, 0xFFFF, 065432
};
main()
{
FILE *input, *output, *fopen();
int i;
long test[NUM_DATA];
char filename[81];
printf("Please input filename!\n");
scanf("%80s", filename);
printf("Data size %d, Elements %d\n", sizeof(data), NUM_DATA);
output = fopen(filename, "wb"); /* binary! */
fwrite(data, sizeof(long), NUM_DATA, output);
fclose(output);
printf("Read Data!\n");
input = fopen(filename, "rb");
printf("%d Elements read\n", fread(test, sizeof(long), NUM_DATA, input));
fclose(input);
for(i = 0; i < NUM_DATA; i++)
printf("%ld\t", test[i]);
printf("\nDone!\n");
}